<?php

/**
 * AtividadesController - Atividades
 *
 * @author Fernando Dias Oliveira <rodox17@gmail.com>
 * @package intranet
 * @subpackage controller
 */

class MapaController extends AppBaseController
{
	public function init()
	{
		parent::init();
		
		$this->view->title = "Mapa";	
	}

    public function indexAction() 
    {
    	$INT008 = new INT008();
    	$INT006 = new INT006();
    	
    	$this->view->projetos = $INT006->getProMap();
    	
    	$field = $this->_request->getPost("parans");
    	$busca = $this->_request->getPost("busca");
    	
    	$this->view->maps = $INT008->getAllMaps($field, trim($busca));
    	
	    foreach ($INT008->getFields() as $key => $val)
		{
			$fields[$val] = $key;
		}
		
    	$this->view->fields = $fields;
    	
		$f = $this->_request->getParam("full");
		
		if($f)
		{
			$this->view->full = "full";
			
			$this->_helper->layout->disableLayout();
		}
    }
    
    public function mapaAction()
    {
    	$this->_helper->layout->disableLayout();
    }
    
    public function dragAction()
    {
    	$this->_helper->layout->disableLayout();
    }
    
    public function salvarpontoAction()
    {
    	$pon = split(",", $this->_request->getPost("ponto"));
    	
    	$sites = new Sites();
    	
    	if($this->_request->isPost())
		{
			$lat = $pon[0];
			$lng = $pon[1];
			
			$sites->setLat($lat);
			$sites->setLng($lng);
			
			$sites->salvar("pontos.xml");
		}
		
		exit;
    }
    
    public function pontoAction()
    {
		$this->view->lat = $this->_request->lat;
		$this->view->lng = $this->_request->lng;
		$this->view->msg = $this->_request->msg;
		
    	$this->_helper->layout->disableLayout();
    }
}
